---
version: '3.4'

networks:
  p2pool:
    driver: bridge

volumes:
  p2pool: 
{% if sidechain[0] == 0 %}
    name: p2pool
{% else %}
    name: p2pool-mini
{% endif %}

{% if configure_monero == True %}
  monero:
    name: monero
{% endif %}

services:
  p2pool:
    image: p2pool:latest
    build: ../
    container_name: p2pool-p2pool
    networks:
      - p2pool
    privileged: true
    ports:
{% if sidechain[0] == 0 %}
      - 37888:37888/tcp
{% else %}
      - 37889:37889/tcp
{% endif %}
{% if expose_stratum_port == True %}
      - {{ stratum_port }}:3333/tcp
{% endif %}
    volumes:
      - p2pool:/home/p2pool/.p2pool:rw
      - /dev/null:/home/p2pool/.p2pool/p2pool.log:rw
      - /dev/hugepages:/dev/hugepages:rw
{% if configure_monero == True %}
    depends_on:
      - monero
{% endif %}
    restart: unless-stopped
    command: >-
{% if configure_monero == True %}
      --host monero
{% else %}
      --host {{ public_monero_node }}
      --rpc-login {{ monero_node_login }}
{% endif %}
      --wallet {{ wallet_address }}
      --loglevel {{ p2pool_log_level | int }}
{% if sidechain[0] == 1 %}
      --mini
{% endif %}
{% if enable_autodiff == False %}
      --no-autodiff
{% endif %}
{% if enable_statistics == True %}
      --local-api
      --data-api /home/p2pool/.p2pool
{% endif %}
{% if light_mode == True %}
      --light-mode
{% endif %}
{% if no_cache == True %}
      --no-cache
{% endif %}
{% if rpc_login != "" %}
      --rpc-login {{ rpc_login }}
{% endif %}
{% if p2pool_options != "" %}
      {{ p2pool_options }}
{% endif %}


{% if enable_statistics == True %}
  statistics:
    image: statistics:latest
    build:
      context: statistics
    container_name: p2pool-statistics
    networks:
      - p2pool
    ports:
      - {{ statistics_port }}:80/tcp
    volumes:
      - p2pool:/data:ro
    depends_on:
      - p2pool
    restart: unless-stopped
{% endif %}


{% if configure_monero == True %}
  monero:
    image: monero:latest
    build:
      context: monero
      args:
        - MONERO_GIT_TAG={{ monero_version }}
    container_name: p2pool-monero
    networks:
      - p2pool
    ports:
      - 18080:18080/tcp
{% if expose_rpc_port == True %}
      - {{ rpc_port }}:18081/tcp
      - 18083:18083/tcp
{% endif %}
    volumes:
      - monero:/home/monero/.bitmonero:rw
      - /dev/null:/home/monero/.bitmonero/bitmonero.log:rw
      - /dev/hugepages:/dev/hugepages:rw
    restart: unless-stopped
    command: >-
      --zmq-pub tcp://0.0.0.0:18083
      --enforce-dns-checkpointing
      --enable-dns-blocklist
      --out-peers 16
      --in-peers 32
      --add-priority-node=nodes.hashvault.pro:18080
      --add-priority-node=p2pmd.xmrvsbeast.com:18080
      --non-interactive
      --p2p-bind-ip=0.0.0.0
      --p2p-bind-port=18080
      --rpc-bind-ip=0.0.0.0
      --rpc-bind-port=18081
      --restricted-rpc
      --confirm-external-bind
      --log-level={{ monero_log_level | int }}
{% if prune_blockchain == True %}
      --prune-blockchain
{% if sync_pruned_blocks == True %}
      --sync-pruned-blocks
{% endif %}
{% endif %}
{% if rpc_login != "" %}
      --rpc-login {{ rpc_login }}
{% endif %}
{% if limit_data_rates == True %}
      --limit-rate-up {{ rate_limit_up }}
      --limit-rate-down {{ rate_limit_down }}
{% endif %}
{% if fast_sync == True %}
      --fast-block-sync=1
{% else %}
      --fast-block-sync=0
{% endif %}
{% if monero_options != "" %}
      {{ monero_options }}
{% endif %}
{% endif %}


{% if configure_xmrig == True %}
  xmrig:
    image: xmrig:latest
    build: xmrig
    container_name: p2pool-xmrig
    networks:
      - p2pool
    privileged: true
    volumes:
      - /dev:/dev:ro
      - /lib/modules:/lib/modules:ro
      - /dev/hugepages:/dev/hugepages:rw
    depends_on:
      - p2pool
    restart: unless-stopped
    command: >-
      --randomx-1gb-pages
      -o p2pool:3333
{% if enable_autodiff == False and use_fixed_difficulty == True %}
      -u {{ xmrig_username }}+{{ fixed_difficulty | int }}
{% else %}
      -u {{ xmrig_username }}
{% endif %}
      --cpu-max-threads-hint={{ cpu_percent | int }}
      --cpu-priority={{ cpu_priority | int }}
{% if xmrig_options != "" %}
      {{ xmrig_options }}
{% endif %}
{% endif %}
